<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	
	protected function _initAuth()
    {
        $this->bootstrap('session');
        $auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
			  $this->bootstrap('view');
            $view = $this->getResource('view');
            $view->user = $auth->getIdentity();
        }
        return $auth;
    }
    
    protected function _initFlashMessenger()
    {
        /** @var $flashMessenger Zend_Controller_Action_Helper_FlashMessenger */
        $flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
        if ($flashMessenger->hasMessages()) {
        	$this->bootstrap('view');
            $view = $this->getResource('view');            
            $view->messages = $flashMessenger->getMessages();
        }
    }
    
    protected function _initCache(){
    	$this->bootstrap('cachemanager');
    	$cacheManager = $this->getResource('cachemanager');
    	Zend_Registry::set('cachePaginator',$cacheManager->getCache('paginator'));    	
    	Zend_Db_Table_Abstract::setDefaultMetadataCache($cacheManager->getCache('database'));    	
    }
}

